﻿// -----------------------------------------------------------------------
// <copyright file="ImageBase.cs" company="Christoph van der Fecht">
// This code can be used in Comercial, free and opensource projects
// </copyright>
// -----------------------------------------------------------------------

namespace MediaTool.Model.Picture
{
    using System;
    using System.ComponentModel;
    using System.Drawing;

    /// <summary>
    /// Base for all images that are supported by the system.
    /// </summary>
    public abstract class ImageBase : INotifyPropertyChanged
    {
        /// <summary>
        /// Name of the <see cref="DateTaken"/> property.
        /// </summary>
        protected const string DateTakenPropertyName = "DateTaken";

        /// <summary>
        /// Timestamp the image was taken or created.
        /// </summary>
        private DateTime dateTaken = DateTime.MinValue;

        /// <summary>
        /// The image.
        /// </summary>
        protected string picturePath = string.Empty;

        /// <summary>
        /// Filename of the picture.
        /// </summary>
        protected string filename = string.Empty;

        /// <summary>
        /// Occures when the value of a property has been changed.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Gets the timestamp the image was taken or created.
        /// </summary>
        public DateTime DateTaken
        {
            get
            {
                return this.dateTaken;
            }

            protected set
            {
                if (value == this.dateTaken)
                {
                    return;
                }

                this.dateTaken = value;
                this.RaisePropertyChanged(DateTakenPropertyName);
            }
        }

        /// <summary>
        /// Raises the <see cref="PropertyChanged"/> event.
        /// </summary>
        /// <param name="propertyName">Name of the property that changed its value.</param>
        protected void RaisePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged !=null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
